﻿
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using Model;
using MsDAL;
using System.ComponentModel;
using Components;
using ServiceHelper;

namespace ServiceHelper
{
    [DataObjectAttribute]
    public partial class Sys0a01Manager : Sys0a01Base
    {
        private static Sys0a01Manager _entity;

        public static Sys0a01Manager Entity
        {
            get
            {
                if (_entity == null)
                    _entity = new Sys0a01Manager();
                return _entity;
            }
        }

        #region 个人代码

        public string SaveData(Hashtable tb, string action, string usercode)
        {
            List<SqlApp> lst = new List<SqlApp>();

            Sys0a01 model = new Sys0a01();
            if (tb != null && tb.Contains("comcode"))
            {
                tb["comcode"] = Validation.ToString(tb["comcode"]).Replace(".", "");
            }

            CommonUtil.GetInstance.CopyProperties(tb, model);

            if ("A" == action)
            {
                model.Muser = usercode;
                model.Mdate = DateTime.Now;
                lst.Add(this.Add(model));
            }
            else if ("M" == action)
            {
                model.Muser = usercode;
                model.Mdate = DateTime.Now;
                lst.Add(this.Update(model));
            }
            else if ("D" == action)
            {
                //删掉权限表中的数据
                lst.Add(Sys0a02Manager.Entity.DeleteByRolecode(model.Rolecode));
                //删掉权限表中的数据
                lst.Add(Sys0a05Manager.Entity.DeleteByRolecode(model.Rolecode));

                lst.Add(Sys0a01Manager.Entity.Delete(model));
            }

            return CommonManager.Entity.SaveData(lst);
        }

        #endregion
    }
}



